package com.pocket.demo.business.service.impl;

import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.pocket.demo.business.dao.MenuMapper;
import com.pocket.demo.business.po.Menu;
import com.pocket.demo.business.service.MenuService;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

/**
 * @author zhaozhile
 */
@Service
public class MenuServiceImpl extends ServiceImpl<MenuMapper, Menu> implements MenuService {
    @Override
    public List<Menu> listAll() {
        return baseMapper.selectList(new QueryWrapper<>());
    }

    @Override
    public List<Menu> listByRoleId(Collection<Long> roleIds) {
        if (CollectionUtil.isEmpty(roleIds)){
            return new ArrayList<>();
        }
        return baseMapper.listByRoleIds(roleIds);
    }
}
